package com.changgou.framework.entity;

import lombok.Getter;
import lombok.Setter;

/**
 * @author Yang
 * @date 2020/11/5
 */
@Getter
@Setter
public class Result {
    private boolean flag;
    private Integer code;
    private String message;
    private Object data;

    private Result() {
    }

    private Result(boolean flag, Integer code, String message, Object data) {
        this.flag = flag;
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public static Result ok(String message,Object data){
        return new Result(true,StatusCode.OK,message,data);
    }
    public static Result ok(Object data){
        return new Result(true,StatusCode.OK,"操作成功",data);
    }
    public static Result error(String message){
        return new Result(false,StatusCode.ERROR,message,null);
    }
}
